import 'dart:convert';

import 'package:flutter_ability/framework/http/request/base_request.dart';

/// 统一网络层返回格式
class HiResponse<T> {
  HiResponse({
    this.data,
    required this.request,
    this.statusCode,
    this.statusMessage,
    this.extra,
  });

  /// 数据data
  T? data;

  /// 封装请求
  BaseRequest request;

  /// code
  int? statusCode;

  /// message
  String? statusMessage;

  late dynamic extra;

  @override
  String toString() {
    if (data is Map) {
      return json.encode(data);
    }
    return data.toString();
  }
}
